<template>
  <div class="app-container">
<!--    隐藏域 记录id-->
    <input type="hidden" v-model="card.id"/>
    <el-form ref="form" :model="card" label-width="120px">
      <el-form-item label="借阅卡id">
        <el-input v-model="card.caid" />
      </el-form-item>
<!--      <el-form-item label="姓名">
        <el-input v-model="student.sname" />
      </el-form-item>-->
      <el-form-item label="留言内容">
        <el-input v-model="card.content" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary"  @click="onSubmit">修改信息</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'
export default {
  data() {
    return {
      card: {
        id:0,
        caid: '',
        content: ''
      },
      student:{
        sname:''
      }
    }
  },
  mounted() {
    this.card=this.$store.state.user.card;
  },
  methods: {
    onSubmit() {
      // 请求接口 实现用户新增接口的调用
      request({
        url:"/library/message/update.do",
        method: "POST",
        data:this.card
      }).then(res=>{
        if(res.code==0){
          //跳转到列表页面
          this.$router.push("/messagelist");
        }
      })
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      });
      this.$router.push("/messagelist");
    }

  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>
